package PaqServidor;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import java.io.*;

public class Servidor {
    public GestorExaminador gestor_t;
    public static XStream xstream = null;
    protected GestorExaminador gestor;

    public Servidor(int backup) {
        xstream = new XStream(new DomDriver());
        //gestor = new Gestor();
        //gestor.cargarDatos();
        try {
            FileInputStream file_input_xml = new FileInputStream(new File("src/Servidor.xml"));
            gestor = (GestorExaminador) xstream.fromXML(file_input_xml);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        realizarBackup();
        gestor.arranca(4444,"localhost");
    }

    private void realizarBackup() {
String xml = xstream.toXML(gestor);
            System.out.println(xml);
            try {
                FileWriter file_output_xml = new FileWriter(new File("src/Servidor.xml"));
                file_output_xml.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
                file_output_xml.write(xml);
                file_output_xml.close();
                //gestor.notificarCambios();
            } catch (IOException e) {
                e.printStackTrace();
            }    
    }
    
    public static void main(String[] args) {
		Servidor server = new Servidor(5);
	}
}